/* oathl.c
 *        - test program of oath totp/hotp algrithm
 *
 * (r) by y.volta@gmail.com
 * (d) 2011/09/18 17:54:59 
 */

#include <stdio.h>
#include <stdlib.h>
#include "oath.h"

void test_hotp ()
{
/*
int
oath_hotp_generate (const char *secret,
size_t secret_length,
uint64_t moving_factor,
unsigned digits,
bool add_checksum,
		    size_t truncation_offset, char *output_otp)
*/

	int       rv = 0;
	char      secret[20] = {0};
	size_t    secret_len = 20;
	uint16_t  factor      = 0;
	unsigned  digits      = 8;
	bool      add_chksum  = 0;
	size_t    trunk_off   = 0;
	char      otp[32]     = {0};

	rv = oath_hotp_generate(secret, secret_len, factor, digits, add_chksum, trunk_off, otp);

}

void test_totp ()
{
/*
int
oath_totp_generate (const char *secret,
size_t secret_length,
time_t now,
unsigned time_step_size,
					time_t start_offset, unsigned digits, char *output_otp)
*/

	int       rv = 0;
	char      secret[20] = "\x3B\x01\xDD\x7A\x3F\x03\x05\xA8\x86\xBB\x77\x49\x36\x96\xF3\x92\x6D\x5C\xBE\x32";
	size_t    secret_len = 20;
	time_t    now         = time(NULL);
	unsigned  digits      = 6;
	unsigned  time_step_size = 60;
	time_t    start_offset= 0;
	char      otp[32]     = {0};

	rv = oath_totp_generate (secret,
		secret_len,
		now,
		time_step_size,
		start_offset, digits, otp);

	printf ("OTP: %s.\n", otp);
}

int main (int argc, char **argv[])
{
	//test_hotp ();
	test_totp ();
}

 